package com.gxa.modules.pc.hospital.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.utils.PageUtils;
import com.gxa.common.utils.Query;
import com.gxa.modules.model.dto.ItemsDto;
import com.gxa.modules.model.dto.PackageTypeDetailDto;
import com.gxa.modules.model.dto.PackageTypeDto;
import com.gxa.modules.model.entity.hospital.Health;
import com.gxa.modules.model.entity.hospital.HospitalPark;
import com.gxa.modules.model.entity.hospital.PackageType;
import com.gxa.modules.model.vo.ItemsVo;
import com.gxa.modules.model.vo.PackageTypeVo;
import com.gxa.modules.pc.hospital.mapper.PackageMapper;
import com.gxa.modules.pc.hospital.mapper.PackageTypeMapper;
import com.gxa.modules.pc.hospital.service.PackageTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 套餐类型 服务实现类
 * </p>
 *
 * @author gxa
 * @since 2022-11-12 05:04:59
 */
@Service
public class PackageTypeServiceImpl extends ServiceImpl<PackageTypeMapper, PackageTypeDto> implements PackageTypeService {

    @Autowired
    private PackageTypeMapper packageTypeMapper;
    @Autowired
    private PackageMapper packageMapper;
    @Override
    public Map<String,Object> queryAll(Integer page, Integer size) {
        Map map = new HashMap();
        Integer newpage = (page-1*size);
        List<PackageTypeDto> packageTypeDtos = this.packageTypeMapper.selectTypeAll(newpage, size);
        Integer count = this.packageTypeMapper.count();
        map.put("items",packageTypeDtos);
        map.put("count",count);
        return map;
    }

    @Override
    public PackageTypeDto queryById(Integer id) {
        PackageTypeDto packageTypeDto = this.packageTypeMapper.queryById(id);
        List<String> strings = this.packageMapper.queryByTypeId(id);
        Integer integer = this.packageMapper.countByTypeId(id);
        packageTypeDto.setCount(integer);
        packageTypeDto.setContext(String.join(",", strings));
        return packageTypeDto;
    }

    @Override
    public void deleteById(List<Long> lists) {
        this.packageTypeMapper.delById(lists);
    }

    @Override
    public void updateStateById(Integer id, Integer state) {
        this.packageTypeMapper.updateStateById(id, state);
    }

    @Override
    public void updateByPackageTypeId(PackageTypeDto packageTypeDto) {
        this.packageTypeMapper.updateByPackageTypeId(packageTypeDto);
    }

    @Override
    public void add(PackageTypeDetailDto packageTypeDetailDto) {
        this.packageTypeMapper.insertPackageType(packageTypeDetailDto);
    }

    @Override
    public List<PackageTypeDto> queryList() {
        List<PackageTypeDto> packageTypeDtos = this.packageTypeMapper.selectTypeList();
        return packageTypeDtos;
    }

    @Override
    public List<HospitalPark> selectParkList() {
        List<HospitalPark> hospitalParks = this.packageTypeMapper.selectParkList();
        return hospitalParks;
    }
}
